package com.loadmore.schedule.util

import android.content.Context
import com.loadmore.common.App
import com.loadmore.common.model.Schedule
import com.loadmore.common.schedule.AlarmUtil

public object ScheduleManager{
    fun init(context: Context) {
        val schedules = App.daoSession.getDao(Schedule::class.java).loadAll()
        if (schedules != null && schedules.isNotEmpty()) {
            for (schedule  in schedules) {
                schedule as Schedule
                if (System.currentTimeMillis() > schedule.end_time) {
                    continue
                }
                val id =schedule.id
                val start_time = schedule.start_time
                val end_time = schedule.end_time
                val repeatType = schedule.repeatType
                val remindType = schedule.remindType
                AlarmUtil.setAlarm(context,id,start_time,end_time,remindType,repeatType)
            }
        }
    }
}